<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>缓存管理</title>
<%@include file="/WEB-INF/common/headeradmin.jsp" %>
</head>
<body style="width:100%;height:100%">
	<div id="pp">
	    <div style="width:33%"></div>
	    <div style="width:33%"></div>
	    <div style="width:33%"></div>
    </div>
    <script type="text/javascript">
 	// 初始化portal,加载数据
	$("#pp").portal({border:false});
	$.get(root+"/admin/config/cache/find",function(json){
		var i = 0;
		for(var key in json){			
			var p = $("<div>").appendTo("body");
			p.panel({
	        	height: 200,
	        	title: key,
	        	collapsible : false,
	        	border: false
	        });
			$("<a href='javascript:void(0)'>启用</a>")
			.linkbutton({
				iconCls:json[key]?"icon-metro-32-checkbox-checked":"icon-metro-32-checkbox-unchecked",
				size:"large",
				iconAlign:"top",
				key:key
			}).click(function(){
				swapEnable($(this), json);
			}).appendTo(p);
			$('#pp').portal('add',{
	            panel:p,
	            columnIndex:i
	        });
			i++;
			if( i % 3 == 0){
				i = 0;
			}
		}
		$("#pp").portal("resize");
	});
	
	function swapEnable(a, json) {
		var span = a.parent("div").find(".l-btn-icon");
		if($(span).hasClass("icon-metro-32-checkbox-checked")){
			$(span).removeClass("icon-metro-32-checkbox-checked").addClass("icon-metro-32-checkbox-unchecked");
			json[a.linkbutton("options").key]=false;
		} else {
			$(span).removeClass("icon-metro-32-checkbox-unchecked").addClass("icon-metro-32-checkbox-checked");
			json[a.linkbutton("options").key]=true;
		}
		console.log(json);
		var ii = layer.load();
		$.post(root+"/admin/config/cache/update", {json:JSON.stringify(json)}).complete(function(){
			setTimeout(function(){
				layer.close(ii);
			}, 3000);
		});
	}
    </script>
</body>
</html>